#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

char* strncpy(char* dest, const char* src, size_t count)
{
	char* ret = dest;
	while (count > 0 && (*dest++ = *src++) != '\0')
	{
		count--;
	}

	if (count)
	{
		while (--count)
		{
			*dest++ = '\0';
		}
	}
	else
	{
		*dest = '\0';
	}
	return ret;
}

int main()
{
	char arr1[20] = "##############";
	char arr2[20] = "abcde";
	char* ret = strncpy(arr1, arr2, 8);
	printf("arr1 = %s\n", arr1);
	return 0;
}